﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
using System.Diagnostics;
using System.Reflection;

namespace LanguageInfo.Common
{
    public static class LoginErr
    {
        //private static log4net.Layout.PatternLayout _layout = new log4net.Layout.PatternLayout("%n===========================================%n异常时间:%date%n异常位置:[%thread] %-5level %logger [%property{NDC}] %n异常信息: %message%newline");

        public static void log(Exception ex)
        {
            //ex.GetBaseException();
            //var abcde = log4net.LogManager.CreateRepository("abcde");
            //log4net.Appender.FileAppender fileappender = new log4net.Appender.FileAppender(_layout, "log\\app2.log", true);
            //log4net.Config.BasicConfigurator.Configure(abcde, fileappender);
            //var log = log4net.LogManager.GetLogger("abcde", typeof(LogHelper));
            //log.Info(message);

            StackTrace stackTrace = new StackTrace();
            MethodBase transfer = stackTrace.GetFrame(1).GetMethod();
            ILog LOGGER = LogManager.GetLogger("Debug");
            string strErrInfo = Environment.NewLine + "方法名称：" + transfer.Name
                + Environment.NewLine + "文件：" + transfer.DeclaringType.FullName
                + Environment.NewLine + "内容：" + ex.Message + Environment.NewLine
                + "详细：" + ex.ToString() + Environment.NewLine;
            LOGGER.Debug(strErrInfo);
        }

        public static void log(Exception ex,string _OtherErrInfo)
        {
            StackTrace stackTrace = new StackTrace();
            MethodBase transfer = stackTrace.GetFrame(1).GetMethod();
            ILog LOGGER = LogManager.GetLogger("Debug");
            string strErrInfo = Environment.NewLine + "方法名称：" + transfer.Name
                + Environment.NewLine + "文件：" + transfer.DeclaringType.FullName
                + Environment.NewLine + "内容：" + ex.Message + Environment.NewLine
                + "详细：" + ex.ToString() + Environment.NewLine
                + "其他信息：" + _OtherErrInfo.ToString() + Environment.NewLine;
            LOGGER.Debug(strErrInfo);
        }
        
    }
}
